// Copyright (c) 2007 Robin Boerdijk. All rights reserved.
//
// This software is licensed under the terms of the Microsoft Reciprocal License as described 
// in the file LICENSE.txt, which you should have received as part of this distribution. The 
// license terms are also available at http://www.opensource.org/licenses/ms-rl.html.

#ifndef wtk_DialogWindow_h_included
#define wtk_DialogWindow_h_included

#include "wtk/Window.h"
#include "wtk/Boxes.h"

#include <string>
#include <vector>
#include <memory>

namespace wtk
{
	class Control;

	class DialogWindow : public Window
	{
	public:

		std::wstring title;

		std::vector<Control *> controls;

		DialogWindow(Window *parentWindow, const std::wstring &title);

		int RunModal();

		static void RunModeless(DialogWindow *dialogWindow);

	protected:

		virtual Box *CreateClientBox() = 0;

	private:

		std::auto_ptr<Box> m_clientBox;

		bool m_runningModeless;

		void Create();

		void Exit(int exitCode);

		SIZE ClientSizeToWindowSize(const SIZE &clientSize);

		void CommitControlPositions();

		void SetDefaultFrameStyle(DWORD defaultFrameStyle);

	protected:

		virtual LRESULT ProcessMessage(HWND windowHandle, UINT message, WPARAM wParam, LPARAM lParam);

	private:

		LRESULT ProcessCloseMessage();

		LRESULT ProcessSizingMessage(RECT &windowRect);

		LRESULT ProcessSizeMessage(const SIZE &clientSize);
	};
}

#endif